const Sequelize = require('sequelize');

import sequelize from './db/sequelize';

/**
 * 单张图片实体
 */
const ManageAdmin = sequelize.define('z_manage_admins', {
  id                    : {type: Sequelize.BIGINT,   allowNull: false, primaryKey: true, autoIncrement: true},
  uid                   : {type: Sequelize.STRING,   allowNull: false, unique:'manage_uid_index' },
  level                 : {type: Sequelize.INTEGER,  allowNull: false },
  username              : {type: Sequelize.STRING,   allowNull: false, unique:'manage_username_index' },
  password              : {type: Sequelize.STRING,   allowNull: false },
  nickname              : {type: Sequelize.STRING,   allowNull: false },
  ext                   : {type: Sequelize.TEXT,     allowNull: true },
  remark                : {type: Sequelize.STRING,   allowNull: true },
  status                : {type: Sequelize.INTEGER,  allowNull: false, defaultValue: 1},
  ctime                 : {type: Sequelize.INTEGER,  allowNull: false},
},
{
    charset: 'utf8'
});

ManageAdmin.sync({force: false}).then(function(){
  // let now = new Date()
  // return ManageAdmin.create({
  //   id:1,
  //   uid:"fdghjkjhgfhjklkjhgf",
  //   level:999,
  //   username:"admin",
  //   password:"123456",
  //   nickname:'测试',
  //   status:1,
  //   ctime:now.getTime() / 1000,
  //   createdAt:now,
  //   updatedAt:now
  // }).then((admin) => {
  //   console.log("create admin",admin);
  // })
});
export default ManageAdmin;